import React, { useEffect, useState } from 'react';
import {getinterviewManage} from '@/services'
import {interViewMage,ISkillInterQuery,interRecord} from '../../utils/interface'
import styles from './interviewManage.less'
import { SearchOutlined } from '@ant-design/icons';
const status = ['不确定', '通过', '未通过' ];
import { Table, Input,Switch} from 'antd';
import {NavLink } from 'umi';
const soundrecordList=['无','有']
const columns=[
    {
        title: '岗位名称',
        render:(row:interRecord)=>
        <NavLink to={`/teachers/interviewRecord?interviewId=${row.interviewId}&shield=${row.shield}&see=true`}>
            <span>{row.stationName}</span>
            </NavLink>
    },
    {
        title: '公司名称',
        dataIndex: 'companyName',
    },
    {
        title: '面试时间',
        dataIndex: 'interviewTime',
    },
    {
        title: '面试官',
        dataIndex: 'intervierManagement',
    },
    {
        title: '专业',
        dataIndex: 'majorName',
    },
    {
        title: '提交人',
        dataIndex: 'commitName',
    },

    {
        title: '面试结果',
        render : (row:interViewMage)=> <span>{status[Number(row.status)]}</span>
    },
    {
        title: '录音文件',
        render : (row:interViewMage)=> <span>{soundrecordList[Number(row.issoundrecord)]}</span>
    },
    {
        title: '屏蔽',
        render:(row:interViewMage)=>{
            if(row.shield===1){
                return <div>
                    <Switch defaultChecked/>
                </div>
            }else{
                return <div>
                    <Switch defaultChecked={false}/>
                </div>
            }
        }
    },
]

const interviewManage:React.FC=()=>{
    let [dataSource, setDataSource] = useState<interViewMage[]>([]);
    let [ searchTitle , SetSearchTitle] = useState('');
    let [title, setTitle] = useState('');
    useEffect(()=>{
        let queryParams : ISkillInterQuery = {} as  ISkillInterQuery;
        queryParams={...queryParams,searchTitle,}
        getinterviewManage(queryParams).then(res=>{
            if(res.code==200){
                setDataSource(res.rows)
            }
        })
    },[searchTitle])

    return <div className='interviewList'>
        <Input className={styles.search}  placeholder="搜索岗位/公司名称" 
        suffix={<SearchOutlined onClick={()=>{ SetSearchTitle(title)}}/>}
         value={title} onChange={e=>setTitle(e.target.value)} onKeyDown={e=>{
                if(e.keyCode === 13)
                {    
                    SetSearchTitle(title)
                }
            }} />
        <Table rowKey="interviewId" dataSource={dataSource} columns={columns} ></Table>
   
       
    </div>
}
export default interviewManage